import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

/**
 * 24点游戏算法
 */
public class TwentyFourPoint {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()) {
            String str[] = scanner.nextLine().split(" ");
            List<Integer> list = new ArrayList<Integer>();
            for (int i=0; i<str.length; i++) {
                list.add(Integer.parseInt(str[i]));
            }
            System.out.println(calculate(list));
        }
    }

    private static boolean calculate(List<Integer> list) {
        for (int i=0; i<list.size(); i++) {
            int temp = list.get(i);
            list.remove(i);
            if (calculate2(list, temp)) {
                return true;
            }
            list.add(i, temp);
        }
        return false;
    }

    private static boolean calculate2(List<Integer> list, int temp) {
        if (list.size()>0) {
            for (int i=0; i<list.size(); i++) {
                int n = list.get(i);
                list.remove(i);
                if(calculate2(list, temp*n) || calculate2(list, temp+n) || calculate2(list, temp-n)) {
                    return true;
                } else if (temp%n == 0) {
                    if (calculate2(list, temp/n)) {
                        return true;
                    }
                }
                list.add(i, n);
            }
            return false;
        } else if (temp == 24) {
            return true;
        } else {
            return false;
        }
    }
}
